#ifndef TB_PREFIX_TYPE_H
#define TB_PREFIX_TYPE_H
#include "keywords.h"

#ifdef __cplusplus
#   define tb_null                  (0)
#else
#   define tb_null                  ((tb_pointer_t)0)
#endif

typedef volatile  __tb_aligned__(4) int   tb_atomic32_t;
#define tb_true                     ((tb_bool_t)1)
#define tb_false                    ((tb_bool_t)0)

// basic
typedef signed int                  tb_int_t;
typedef unsigned int                tb_uint_t;
typedef signed short                tb_short_t;
typedef unsigned short              tb_ushort_t;
typedef tb_int_t                    tb_bool_t;
typedef signed char                 tb_int8_t;
typedef tb_int8_t                   tb_sint8_t;
typedef unsigned char               tb_uint8_t;
typedef tb_short_t                  tb_int16_t;
typedef tb_int16_t                  tb_sint16_t;
typedef tb_ushort_t                 tb_uint16_t;
typedef tb_int_t                    tb_int32_t;
typedef tb_int32_t                  tb_sint32_t;
typedef tb_uint_t                   tb_uint32_t;
typedef char                        tb_char_t;
typedef unsigned char               tb_uchar_t;
typedef tb_uint8_t                  tb_byte_t;
typedef void                        tb_void_t;
typedef tb_void_t*                  tb_pointer_t;
typedef tb_void_t const*            tb_cpointer_t;
typedef tb_pointer_t                tb_handle_t;


typedef signed long                 tb_long_t;
typedef unsigned long               tb_ulong_t;
typedef tb_ulong_t                  tb_size_t;


typedef signed long long            tb_int64_t;
typedef unsigned long long          tb_uint64_t;
typedef tb_int64_t                  tb_sint64_t;

// hong and hize
typedef tb_sint64_t                 tb_hong_t;
typedef tb_uint64_t                 tb_hize_t;

// no argument
#ifdef __cplusplus
#   define tb_noarg_t
#else
#   define tb_noarg_t               tb_void_t
#endif

typedef __tb_volatile__ struct __tb_atomic_flag_t
{
    tb_atomic32_t __val;
}tb_atomic_flag_t;
/// the spinlock type
#if 0
typedef tb_atomic_flag_t            tb_spinlock_t;
#else
typedef __tb_volatile__ int            tb_spinlock_t;
#endif
/// the spinlock ref type
typedef tb_spinlock_t*              tb_spinlock_ref_t;


typedef union __tb_value_t
{
    /// uint8
    tb_uint8_t                      u8;

    /// sint8
    tb_sint8_t                      s8;

    /// char
    tb_char_t                       c;

    /// wchar
    // tb_wchar_t                      wc;

    /// boolean
    tb_bool_t                       b;

    /// uint16
    tb_uint16_t                     u16;

    /// sint16
    tb_sint16_t                     s16;

    /// uint32
    tb_uint32_t                     u32;

    /// sint32
    tb_sint32_t                     s32;

    /// size
    tb_size_t                       ul;

    /// long
    tb_long_t                       l;


}tb_value_t, *tb_value_ref_t;


typedef __tb_typeref__(mutex);
typedef __tb_typeref__(file);
#endif